using namespace std;

void readFromFile(string fileName, vector<string>& lines)
{
	ifstream infile(fileName.c_str()); // open file
	string in;
	string token;
	stringstream iss;

	while (infile){
		if (infile.eof()){
                    infile.close();
        }
		else 
		{
			getline(infile, in);
			iss << in;
			bool eol = false;
			bool cparen = false;
			bool ccparen = false;
			bool quote = false;

			while (getline(iss, token, ' '))
			{
				if(token[token.size()-1] == ';')
				{
					token.erase(token.size()-1, 1);
					eol = true;
				}

				if(token[0]=='(')
				{
					lines.push_back("(");
					token.erase(0,1);
				}
				if(token[token.size()-1]==')')
				{
					if(token[token.size()-2]==')')
					{
						ccparen = true;
						token.erase(token.size()-1,1);
					}

					token.erase(token.size()-1,1);
					cparen = true;
				}

				if(token[token.size()-1] == ',')
				{
					token.erase(token.size()-1, 1);
				}

				lines.push_back(token);

				if(cparen)
				{
					lines.push_back(")");
					cparen = false;
				}
				if(ccparen)
				{
					lines.push_back(")");
					ccparen = false;
				}
				if(eol)
				{
					program(lines);
					lines.clear();
				}
			}
			iss.clear();
		}
	}
}
